﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace WFONE
{
    public partial class AddDeDataSl : Form
    {

        CDeDataSl cdedataSl = new CDeDataSl();
          // AddDevice.cdevice1.cDeDataSingleListHead;
        public AddDeDataSl()
        {
            InitializeComponent();
        }

        public bool inputBool()//输入数据完整提示
        {
            if ( tBRs.Text == "" || tBGp.Text == ""
                || tBRx.Text == "" || tBRp.Text == "" || tBAngle.Text == "")
            {
                return false;
            }
            else
            {
                return true;
            }
        }
       
         
        private void tBAddData_MouseClick(object sender, MouseEventArgs e)
        {
            if (inputBool() == true)
            {
                try
                {
                    cdedataSl.dRs = Math.Round(double.Parse(tBRs.Text));
                    cdedataSl.dGp = Math.Round(double.Parse(tBGp.Text));
                    cdedataSl.dRx = Math.Round(double.Parse(tBRx.Text));
                    cdedataSl.dRp = Math.Round(double.Parse(tBRp.Text));
                    cdedataSl.dPAngle = Math.Round(double.Parse(tBAngle.Text));
                    cdedataSl.datetime = DateTime.Now;
                    AddDevice.cdevice1.AddDeData(cdedataSl) ;
                    MessageBox.Show("成功添加设备和设备的第一个设备数据", "提示", MessageBoxButtons.OK);
                    this.Close();           
                }
                catch (Exception ex)
                {
                    MessageBox.Show(ex.ToString());
                }

            }
            else
            {
                MessageBox.Show("请输入完整数据", "提示信息", MessageBoxButtons.OK);                
            }
        }
    }
}
